{include file="public/nheader"}
<div class="layui-fluid layui-bg-white">
    <form action="{:url()}" class="layui-form layui-form-fixed">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>备注
            </label>
            <div class="layui-input-block">
                <input type="text" id="name" name="data[nickname]" value="{$data.nickname|default=''}" required=""
                    lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>账号
            </label>
            <div class="layui-input-block">
                <input type="text" id="username" name="data[username]" value="{$data.username|default=''}" required=""
                    lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>密码
            </label>
            <div class="layui-input-block">
                <input type="password" id="password" name="data[password]" value="" autocomplete="off"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>品牌权限
            </label>
            <div class="layui-input-block">
                <div class="layui-card-body layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <input type="checkbox" name="like1[write]" lay-skin="primary" lay-filter="father"
                            title="全选">
                    </div>
                    <div class="layui-col-md12">
                        {foreach $pinpai as $k => $v}
                        <input name="data[groups][]" lay-skin="primary" type="checkbox" value="{$v.type}" title="{$v.pinpai}"
                            {if !empty($data.groups) && in_array($v.type, $data.groups)} checked {/if}>
                        {/foreach}
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <font color="red">* </font>功能权限
            </label>
            <div class="layui-input-block">
                {foreach :config('menu.menu') as $k => $v}
                <div class="layui-card-body layui-row layui-col-space10">
                    {if $v.show == true}
                    <div class="layui-col-md12">
                        <input type="checkbox" name="like1[write]" lay-skin="primary" lay-filter="father"
                            title="{$v.name}">
                    </div>
                    <div class="layui-col-md12">
                        {foreach $v.sub as $x => $y}
                        <input name="data[role][]" lay-skin="primary" type="checkbox" value="{$y.uri}" title="{$y.name}"
                            {if !empty($data.role) && in_array($y.uri, $data.role)} checked {/if}>
                        {/foreach}
                    </div>
                    <hr />
                    {/if}
                </div>
                {/foreach}
            </div>
        </div>
        <div class="layui-footer layui-form-item layui-center ">
            <input type="hidden" value="{$data.id|default='0'}" name="data[id]" />
            <button class="layui-btn" lay-filter="submitIframe" type="button" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">取消</button>
        </div>
    </form>
</div>
{include file="public/nfooter"}
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        form.on('checkbox(father)', function (data) {
            if (data.elem.checked) {
                $(data.elem).parent().next('div').find('input').prop("checked", true);
                form.render();
            } else {
                $(data.elem).parent().next('div').find('input').prop("checked", false);
                form.render();
            }
        });
    });
</script>